package com.app.shop.activitys;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


import com.app.library.base.BaseActivity;
import com.app.library.beans.EventMessage;
import com.app.library.utils.UserManager;
import com.app.shop.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class  MyInfoActivity extends BaseActivity {


    private TextView tvTitle;
    private TextView tvName;
    private TextView tvMobile;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_info);
        tvTitle= (TextView) findViewById(R.id.tv_title);
        tvName= (TextView) findViewById(R.id.tv_name);
        tvMobile= (TextView) findViewById(R.id.tv_mobile);
     ImageView imgvreturn= (ImageView) findViewById(R.id.imgv_return);
        tvMobile.setOnClickListener(this::onViewClicked);
        tvName.setOnClickListener(this::onViewClicked);
        imgvreturn.setOnClickListener(this::onViewClicked);
        tvTitle.setText("个人信息");

        tvName.setText("姓名：" + UserManager.getUserName(this));
        tvMobile.setText("手机号：" + UserManager.getMobile(this));
    }

    @Override
    public void onEvent(EventMessage msg) {
        super.onEvent(msg);
        if (msg.getMessageType() == EventMessage.REFRESH) {
            tvName.setText("姓名：" + UserManager.getUserName(this));
            tvMobile.setText("手机号：" + UserManager.getMobile(this));
        }
    }


    public void onViewClicked(View view) {
        switch (view.getId()) {

            case R.id.imgv_return:
                onBackPressed();

                break;
            case R.id.tv_name:
                Bundle bundle = new Bundle();
                bundle.putInt("from", 0);
                showActivity(this, ModifyActivity.class, bundle);
                break;
            case R.id.tv_mobile:
                Bundle bundle1 = new Bundle();
                bundle1.putInt("from", 1);
                showActivity(this, ModifyActivity.class, bundle1);
                break;
        }
    }
}
